**********************************************************************************
* The code in this file will replicate Figures 1 and 2 and Table 2
* in the main text.  It was also replicate the Table A-1 in the
* supplentary appendix.
*
* For Figures 1 and 2 and Table A-1, the data are in the file OfftheMenuWarDeclarations.dta
* For Table 2, the data in the file OfftheMenuArticle51.dta
***********************************************************************************



*************
* Figure 1
*************

* Figure 1a: probability of war declartions by year

use OfftheMenuWarDeclarations, clear

forvalues i=1/3 {

	capture drop yr`i' post45_yr`i' pre45_yr`i'
	gen yr`i'=(1945-cowstartyr)^`i'
	gen post45_yr`i'=post45*yr`i'
	gen pre45_yr`i'=(1-post45)*yr`i'
	}
	
logit newdeclare pre45_yr1 pre45_yr2 pre45_yr3 post45 post45_yr1 post45_yr2 post45_yr3, cluster(warnum)

predict dhat, xb

foreach i in 0 1 {
	gen dhat`i'=invlogit(dhat) if post45==`i'
	
	}

graph set window fontface "Garamond"

line dhat0 dhat1 cowstartyr, lpattern(solid solid) graphregion(color(white)) bgcolor(white) scheme(s2mono) legend(off) ytitle("Pr(War Declaration)") name(fig1a, replace) xlabel(1825(20)2005) xtitle("Year")


* Figure 1b:  IHL ratifications by decade

* drop duplicates to reduce dyad data to war participant level
duplicates drop warnum ccode1, force

* generate 10 years average, min and max
egen avrat=mean(ratifications),by(tenyear)
egen minrat=min(ratifications),by(tenyear)
egen maxrat=max(ratifications),by(tenyear)

label var tenyear "Ten-Year Period"


duplicates drop tenyear, force
sort tenyear
twoway (rarea maxrat minrat tenyear, lwidth(none))  (line avrat tenyear, lpattern(solid)), graphregion(color(white)) bgcolor(white) scheme(s2mono) legend(off) ytitle("Number of Ratifications") xlabel(1825(10)2005,alt) name(fig1b, replace)

* combine to make Figure 1
graph combine fig1a fig1b, col(1) iscale(1) scheme(s2mono) graphregion(color(white))

*************
* Figure 2
*************
use OfftheMenuWarDeclarations, clear

gen rat=.
gen pdeclare=.
gen pdeclare_pre=.
gen pdeclare_post=.

local i=1

forvalues r=0/40 {

	qui replace rat=`r' in `i'
		
	qui summ newdeclare if ratifications==`r'
	qui replace pdeclare=r(mean) in `i'

	qui summ newdeclare if ratifications==`r'&post45==1
	qui replace pdeclare_post=r(mean) in `i'

	qui summ newdeclare if ratifications==`r'&post45==0
	qui replace pdeclare_pre=r(mean) in `i'
	
	local i=`i'+1
	
	}
	
label var pdeclare "Full sample"
label var pdeclare_pre "Pre-1945"
label var pdeclare_post "Post-1945"
label var rat "Ratifications"

lowess pdeclare rat, gen(pdeclare_tot)
label var pdeclare_tot "Overall trend"

twoway (line pdeclare_tot rat) (scatter pdeclare_pre rat, msymbol(o) mcolor(gs0) ) (scatter pdeclare_post rat, msymbol(Dh) mcolor(gs0)), graphregion(color(white)) scheme(s2mono) legend(cols(3) pos(12) region(style(none))) ytitle("Frequency of War Declarations") 



****************************
* Replicate Appendix Tables
****************************

use OfftheMenuWarDeclarations, clear

* original Fazal Table 3.1, model 3
logit newdeclare ratifications un initiate polity polconiii_2002 coin Eurovsnon reciprocal bothgreat, robust cluster(warnum)
outreg2 using table1.doc, word label se dec(3) replace

* replace Polity with regime type indicators
logit newdeclare ratifications un initiate dem aut politymiss coin Eurovsnon reciprocal bothgreat, robust cluster(warnum)
outreg2 using table1.doc, word label se dec(3) append

*  add post45 dummy
logit newdeclare ratifications un post45 initiate dem aut politymiss coin Eurovsnon reciprocal bothgreat, robust cluster(warnum)
outreg2 using table1.doc, word label se dec(3) sortvar(ratifications un post45 initiate polity polconiii_2002 dem aut politymiss coin Eurovsnon reciprocal bothgreat) append

* split sample: pre-1945
logit newdeclare ratifications de initiate dem aut politymiss coin Eurovsnon reciprocal bothgreat if post45==0, robust cluster(warnum)
outreg2 using table1.doc, word label se dec(3) sortvar(ratifications un  post45 initiate polity polconiii_2002 dem aut politymiss coin Eurovsnon reciprocal bothgreat) append

*split sample: post-1945
logit newdeclare ratifications if post45==1, robust cluster(warnum)
outreg2 using table1.doc, word label se dec(3) sortvar(ratifications un post45  initiate polity polconiii_2002 dem aut politymiss coin Eurovsnon reciprocal bothgreat) append


************************************************************
* Analyze Article 51 letters and IHL Ratifications (Table 2)
************************************************************

use OfftheMenuArticle51, clear

* create Table 2
tab art51 ihl if unsc==0, col chi
